﻿using SmartAnswerPlatform.IRepository;
using SmartAnswerPlatform.Models.Entitys.Base;
using SmartAnswerPlatform.Models.ViewModels.Base;
using System.Linq.Expressions;

namespace SmartAnswerPlatform.IService
{
    public interface IBaseService<TEntity, TViewModel> where TEntity : BaseEntity, new()
    {
        /// <summary>
        /// 根据id查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns>查询到的实体</returns>
        Task<TViewModel> FindById(string id);
        /// <summary>
        /// 根据多个id查询
        /// </summary>
        /// <param name="ids">id集合</param>
        /// <returns>查询到的多个实体集合</returns>
        Task<List<TViewModel>> FindByIds(List<string> ids);
        /// <summary>
        /// 查询全部内容
        /// </summary>
        /// <returns>返回所有内容</returns>
        Task<List<TViewModel>> FindAll();
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">修改实体</param>
        /// <returns>受影响行数</returns>
        Task<int> Update(TViewModel viewModel);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="entities">需要修改的实体集合</param>
        /// <returns>受影响行数</returns>
        Task<int> UpdateRange(List<TViewModel> viewModels);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">id主键</param>
        /// <returns>删除的受影响行数</returns>
        Task<int> Delete(string id);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids">id集合</param>
        /// <returns>受影响行数</returns>
        Task<int> DeleteRange(List<string> ids);
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">添加的实体</param>
        /// <returns>添加后的实体</returns>
        Task<TViewModel> Insert(TViewModel viewModel);
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="entities">需要添加的实体集合</param>
        /// <returns>添加后的受影响行数</returns>
        Task<int> InsertRange(List<TViewModel> viewModels);


    }
}
